<?php

namespace PHPMailer;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception; 

class Mail 
{
    
    public static function send($email,$title,$content)
    {


        $mail = new PHPMailer(true);

        // Passing `true` enables exceptions
        try {
            //Server settings
            $mail->SMTPDebug = 2;

            $mail->Hostname = "www.abc.com";

            $mail->CharSet = 'UTF-8';                                 // Enable verbose debug output
            $mail->isSMTP();                                      // Set mailer to use SMTP
            $mail->Host = config('email.host');  // Specify main and backup SMTP servers
            $mail->SMTPAuth = true;                               // Enable SMTP authentication
            $mail->Username = config('email.user');                 // SMTP username
            $mail->Password = config('email.pwd');                           // SMTP password
            $mail->SMTPSecure = config('email.SMTPSecure');                   // Enable TLS encryption, `ssl` also accepted
            $mail->Port = config('email.port');
            //Recipients
            $mail->setFrom(config('email.user'), config('email.myname'));

            // $mail->addAddress(config('email.user'));
            $mail->addAddress($email);
            // $mail->addCC($email);     

            //Content
            $mail->isHTML(true);                                  // Set email format to HTML
            $mail->Subject = $title;
            $mail->Body    = $content;

            $mail->send();

            return true;
        } catch (Exception $e) {
            return  $mail->ErrorInfo;
        }
    }
}
